package com.fgaejiang.io;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.monitor.FileAlterationMonitor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.util.concurrent.Executor;

/**
 * 我还没有写描述
 *
 * @author <发哥讲Java-694204477@qq.com>
 * @version 1.0
 * @date 2021/6/9 21:04
 */
@Component
@Slf4j
public class ApplicationBizRunner implements ApplicationRunner {

    @Autowired
    FileListenerFactory fileListenerFactory;

    @Autowired
    Executor customExecutor;

    @Override
    public void run(ApplicationArguments args) throws Exception {
        FileAlterationMonitor monitor = fileListenerFactory.getMonitor();
        // 在线程池中执行.. todo 不能使用线程池执行,
//        customExecutor.execute(monitor);
        monitor.start();
        System.out.println("***************监控开始***************");
    }
}
